import cv2 as cv

filename=r'E:\python\Lenna_(test_image).png'
img=cv.imread(filename)
#gray=cv.cvtColor(img,cv.COLOR_BGR2GRAY)

cv.imshow("source image",img)
#cv.imshow("gray",gray)
#cv.waitKey()

hsv=cv.cvtColor(img,cv.COLOR_BGR2HSV)

cv.imshow("HUE",hsv[:,:,0])#输出HSV图像的H分量
cv.imshow("Saturation",hsv[:,:,:1])#输出HSV图像的S分量
cv.imshow("Value",hsv[:,:,2])#输出HSV图像的I分量
#cv.waitKey()


cv.imshow("Blue",img[:,:,0])#输出RGB图像的B分量
cv.imshow("GREEN",img[:,:,1])#输出RGB图像的G分量
cv.imshow("RED",img[:,:,2])#输出RGB图像的R分量

cv.waitKey()
cv.destroyAllWindows()